import 'package:base_plugin/base_plugin.dart';
import 'package:dio/dio.dart';

class HttpReportService {
  static Future<Response> salesByPeriod(
      {String start_date, String end_date, int contact_id, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/sales', {
      'start_date': start_date,
      'end_date': end_date,
      'contact_id': contact_id,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> salesCustomer(
      {String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/sales/contacts', {
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> salesProducts(
      {String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/sales/products', {
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> salesAgedSummary(
      {String as_at, int contact_id, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/sales/aged_summary', {
      'as_at': as_at,
      'contact_id': contact_id,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> salesAgedDetail(
      {String as_at, int contact_id, int is_pdf, int is_excel}) {
    return BaseConfig.httpBase.get('/api/reports/sales/aged_detail', {
      'as_at': as_at,
      'contact_id': contact_id,
      'is_pdf': is_pdf,
      'is_excel': is_excel,
    });
  }

  static Future<Response> purchasesByPeriod(
      {String start_date, String end_date, int contact_id, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/purchases', {
      'start_date': start_date,
      'end_date': end_date,
      'contact_id': contact_id,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> purchasesBySupplier(
      {String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/purchases/contacts', {
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> purchasesByProducts(
      {String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/purchases/products', {
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> purchasesByAgedSummary(
      {String as_at, int contact_id, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/purchases/aged_summary', {
      'as_at': as_at,
      'contact_id': contact_id,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> purchasesByAgedDetail(
      {String as_at, int contact_id, int is_pdf, int is_excel}) {
    return BaseConfig.httpBase.get('/api/reports/purchases/aged_detail', {
      'as_at': as_at,
      'contact_id': contact_id,
      'is_pdf': is_pdf,
      'is_excel': is_excel,
    });
  }

  static Future<Response> profits(
      {String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/profits', {
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> balanceSheets(
      {String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/balance_sheets', {
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> generalLedgers(
      {String start_date, String end_date, int is_pdf, int page}) {
    return BaseConfig.httpBase.get('/api/reports/general_ledgers', {
      'page': page,
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> generalLedgersDetail(
      {String coa_account, String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/general_ledgers/detail', {
      'start_date': start_date,
      'end_date': end_date,
      'coa_account': coa_account,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> payrollMonthlySummary({String date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/payslips', {
      'date': date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> cashFlow(
      {String start_date, String end_date, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/cash_flow', {
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> journalEntries(
      {String start_date, String end_date, int is_pdf, int page}) {
    return BaseConfig.httpBase.get('/api/reports/journal_entries', {
      'page': page,
      'start_date': start_date,
      'end_date': end_date,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> fixedAssets({int is_pdf, int is_json}) {
    return BaseConfig.httpBase.get(
        '/api/reports/fixed_assets', {'is_pdf': is_pdf, 'is_json': is_json});
  }

  static Future<Response> fixedAssetsHistory({int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/fixed_assets/history', {
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> inventories({String as_at, int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/inventories', {
      'as_at': as_at,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> inventoriesDetail(
      {String start_date,
      String end_date,
      int product_id,
      int is_pdf,
      int is_excel}) {
    return BaseConfig.httpBase.get('/api/reports/inventories/detail', {
      'start_date': start_date,
      'end_date': end_date,
      'product_id': product_id,
      'is_pdf': is_pdf,
      'is_excel': is_excel,
    });
  }

  //获取GST F5时间
  static Future<Response> taxSubmissions() {
    return BaseConfig.httpBase.get('/api/reports/tax_submissions', {});
  }

  //更新balance
  static Future<Response> taxSubmissionsBalance(int id, List lines) {
    return BaseConfig.httpBase
        .postJson('/api/reports/tax_submissions/$id/balances', {
      'lines': lines,
    });
  }

  //更新GST F5 balance
  static Future<Response> gstF5Balance(int id, List lines) {
    return BaseConfig.httpBase
        .putJson('/api/reports/tax_submissions/$id/line/balances', {
      'lines': lines,
    });
  }

  //获取GST详情
  static Future<Response> taxSubmissionsDetail(int id, {int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/tax_submissions/$id/detail', {
      'is_pdf': is_pdf,
    });
  }

  //获取GST详情
  static Future<Response> taxSubmissionsDetailGST(int id, {int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/tax_submissions/$id/gst', {
      'tax_submission_id': id,
      'is_pdf': is_pdf,
    });
  }

  //获取GST详情
  static Future<Response> taxComputation({int is_pdf}) {
    return BaseConfig.httpBase
        .get('/api/reports/tax_submissions/0/computation', {
      'line_submission_id': 0,
      'is_pdf': is_pdf,
    });
  }

  //accept
  static Future<Response> taxComputationAccept(int id) {
    return BaseConfig.httpBase
        .postJson('/api/reports/tax_submissions/$id/computation/accept', {
      'line_submission_id': id,
    });
  }

  //获取GST详情
  static Future<Response> taxSubmissionsSubmitted(int id) {
    return BaseConfig.httpBase
        .postJson('/api/reports/tax_submissions/$id/submit', {
      'line_submission_id': id,
    });
  }

  static Future<Response> taxSubmissionsLine(int line, int taxSubmissionId,
      {int is_pdf}) {
    return BaseConfig.httpBase
        .get('/api/reports/tax_submissions/$taxSubmissionId/line/$line', {
      'tax_submission_id': taxSubmissionId,
      'line': line,
      'is_pdf': is_pdf,
    });
  }

  static Future<Response> bankReconciliationDetail(int bankReconciliation,
      {int is_pdf}) {
    return BaseConfig.httpBase.get('/api/reports/reconciliation', {
      'is_pdf': is_pdf,
      'reconciliation_id': bankReconciliation,
    });
  }

// static Future<Response> purchasesByAgedDetail(
//     {String as_at, int contact_id}) {
//   return BaseConfig.httpBase.get('/api/reports/tax_submissions', {
//     'as_at': as_at,
//     'contact_id': contact_id,
//   });
// }
}
